headerbar: fix leak of label_sizing_box
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 12 Oct 2016 15:38:13 +0000 (16:38 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 13 Oct 2016 13:39:02 +0000 (09:39 -0400)
Since the widget is not added to a container, we have the responsibility
to sink the initial floating reference, and ultimately to unref it.

https://bugzilla.gnome.org/show_bug.cgi?id=772859

gtk/gtkheaderbar.c

index 40f5d3dc6597c2711f35da16027fbb28e6486af1..e467326e2a8d9d9dcce2bddf2ed0a246261cf021 100644 (file)
@@ -133,8 +133,9 @@ init_sizing_box (GtkHeaderBar *bar)
    * the real label box with its actual size, to keep it center-aligned
    * in case we have only the title.
    */
-  priv->label_sizing_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  gtk_widget_show (priv->label_sizing_box);
+  w = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_widget_show (w);
+  priv->label_sizing_box = g_object_ref_sink (w);
 
   w = gtk_label_new (NULL);
   gtk_widget_show (w);
@@ -1466,6 +1467,12 @@ gtk_header_bar_destroy (GtkWidget *widget)
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget));
 
+  if (priv->label_sizing_box)
+    {
+      gtk_widget_destroy (priv->label_sizing_box);
+      g_clear_object (&priv->label_sizing_box);
+    }
+
   if (priv->custom_title)
     {
       gtk_widget_unparent (priv->custom_title);